/*
 Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.

 Licensed under the Apache License, Version 2.0 (the "License").
 You may not use this file except in compliance with the License.
 A copy of the License is located at

 http://aws.amazon.com/apache2.0

 or in the "license" file accompanying this file. This file is distributed
 on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 express or implied. See the License for the specific language governing
 permissions and limitations under the License.
 */

#import <Foundation/Foundation.h>

FOUNDATION_EXPORT NSString *const CSPDateRFC822DateFormat1;
FOUNDATION_EXPORT NSString *const CSPDateISO8601DateFormat1;
FOUNDATION_EXPORT NSString *const CSPDateISO8601DateFormat2;
FOUNDATION_EXPORT NSString *const CSPDateISO8601DateFormat3;
FOUNDATION_EXPORT NSString *const CSPDateShortDateFormat1;

@interface NSDate (CSP)

+ (NSDate *)csp_clockSkewFixedDate;

+ (NSDate *)csp_dateFromString:(NSString *)string;
+ (NSDate *)csp_dateFromString:(NSString *)string format:(NSString *)dateFormat;
- (NSString *)csp_stringValue:(NSString *)dateFormat;

/**
 * Set the clock skew for the current device.  This clock skew will be used for calculating
 * signatures to CSP signatures and for parsing/converting date values from responses.
 *
 * @param clockskew the skew (in seconds) for this device.  If the clock on the device is fast, pass positive skew to correct.  If the clock on the device is slow, pass negative skew to correct.
 */
+ (void)csp_setRuntimeClockSkew:(NSTimeInterval)clockskew;

/**
 * Get the clock skew for the current device.
 *
 * @return the skew (in seconds) currently set for this device.  Positive clock skew implies the device is fast, negative implies the device is slow.
 */
+ (NSTimeInterval)csp_getRuntimeClockSkew;

@end

@interface NSDictionary (CSP)

- (NSDictionary *)csp_removeNullValues;
- (id)csp_objectForCaseInsensitiveKey:(id)aKey;

@end

@interface NSJSONSerialization (CSP)

+ (NSData *)csp_dataWithJSONObject:(id)obj
                           options:(NSJSONWritingOptions)opt
                             error:(NSError **)error;

@end

@interface NSNumber (CSP)

+ (NSNumber *)csp_numberFromString:(NSString *)string;

@end

@interface NSObject (CSP)

- (NSDictionary *)csp_properties;
- (void)csp_copyPropertiesFromObject:(NSObject *)object;
- (NSString *)csp_toJSONString;

@end

@interface NSString (CSP)

+ (NSString *)csp_base64md5FromData:(NSData *)data;
+ (NSString *)csp_baseUserAgent;
- (BOOL)csp_isBase64Data;
- (NSString *)csp_stringWithURLEncoding;
- (NSString *)csp_stringWithURLEncodingPath;
- (NSString *)csp_stringWithURLEncodingPathWithoutPriorDecoding;
- (NSString *)csp_md5String;
- (NSString *)csp_md5StringLittleEndian;
- (BOOL)csp_isVirtualHostedStyleCompliant;
- (id)csp_parseJSON;

@end

@interface NSFileManager (CSP)

- (BOOL)csp_atomicallyCopyItemAtURL:(NSURL *)sourceURL
                              toURL:(NSURL *)destinationURL
                     backupItemName:(NSString *)backupItemName
                              error:(NSError **)outError;

@end
